package com.emcom.gotour.dao.ibatis;

import java.util.List;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.emcom.gotour.dao.TourSchedulerDao;
import com.emcom.gotour.po.TourScheduler;
import com.ibatis.sqlmap.client.SqlMapClient;

public class IbatisTourSchedulerDao implements TourSchedulerDao {

	private SqlMapClientTemplate sqlMapClientTemplate;

	public TourScheduler query(long id) {
		TourScheduler tourScheduler = new TourScheduler();
		tourScheduler.setId(id);
		List<TourScheduler> tourSchedulerList = query(tourScheduler);
		if(tourSchedulerList.size() == 1) {
			return tourSchedulerList.get(0);
		}
		return null;
	}

	public List<TourScheduler> query(TourScheduler tourScheduler) {
		return sqlMapClientTemplate.queryForList("TourScheduler.query", tourScheduler);
	}

	public void update(TourScheduler tourScheduler) {
		sqlMapClientTemplate.update("TourScheduler.update", tourScheduler);
	}

	public void insert(TourScheduler tourScheduler) {
		sqlMapClientTemplate.insert("TourScheduler.insert", tourScheduler);
	}

	public void delete(TourScheduler tourScheduler) {
		sqlMapClientTemplate.delete("TourScheduler.delete", tourScheduler);
	}

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClientTemplate = new SqlMapClientTemplate();
		this.sqlMapClientTemplate.setSqlMapClient(sqlMapClient);
	}

}
